package com.zh.zhbootcommon.config.log;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.LogData;
import com.github.collector.LogCollector;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 描述: AOP 日志切面收集
 *
 * @author: yanglin
 * @Date: 2021-08-19-13:33
 * @Version: 1.0
 */
@Slf4j
@Component
public class AopLogCollector implements LogCollector {

    private ObjectMapper objectMapper = new ObjectMapper();
    @Override
    public void collect(LogData logData) {
        try {
            log.info(objectMapper.writeValueAsString(logData));
        } catch (JsonProcessingException e) {
            log.error("AopLogCollector->{}", e.getMessage());
        }
    }
}
